<div class="brw_tip">
	<div class="t_con">
		系统检测到您的浏览器版本过低，无法获得最佳的使用体验，建议您更换其他浏览器或 <a href="https://www.google.cn/intl/zh-CN/chrome/"
			target="_blank">升级您的浏览器</a>。(使用360浏览器访问请选择极速模式)
		<div class="b_close J_bw_close">关闭</div>
	</div>
</div>
<div id="headerContent">
	<div class="header_wrapper" v-cloak>
		<div class="header clearfix">
			<div class="header_left clearfix">
                <div class="subsite_btn left" v-if="subsite_open==1&&subsite_list.length<10" @click.stop="subsite_sel = 1">
                    <a class="current_city">{#$subsite.sitename|default="总站"#}</a>
                    <span class="switch_city">[切换城市]</span>
                </div>
				<a class="subsite_btn left" v-if="subsite_open==1&&subsite_list.length>9" href="{#:url('index/subsitelist/show')#}">
					<span class="current_city">{#$subsite.sitename|default="总站"#}</span>
					<span class="switch_city">[切换城市]</span>
				</a>
                <a class="left_item homeImg" href="{#:url('index/index/index')#}" v-if="subsite_open==0">网站首页</a>
                <a class="left_item" href="javascript:;" @click="AddFavorite" v-if="subsite_open==0">设为收藏</a>
                <a class="left_item" href="{#:url('index/shortcut/index')#}" v-if="subsite_open==0">保存桌面</a>
                <a href="{#:url('index/job/index')#}" v-if="subsite_open==0">搜职位</a>
			</div>
			<div class="header_right clearfix">
				<span class="right_item" v-if="isLogin===true">
					<span>欢迎 <span class="header_color1 member_center"
							@click="handlerMemberCenter">{{loginUsername}}</span> <span>登录，</span><span
							class="header_color2" @click="handlerLogout">退出</span></span>
				</span>
				<el-dropdown class="drop" @command="handleManageClick" v-if="isLogin===true">
					<a class="right_item header_login" href="javascript:;" @click="handlerMemberCenter">管理中心<i
							class="el-icon-arrow-down el-icon--right"></i></a>
					<el-dropdown-menu slot="dropdown">
						<el-dropdown-item v-if="utype==2" command="handlerRefreshResume">刷新简历</el-dropdown-item>
						<el-dropdown-item v-if="utype==2" command="handlerResumeIndex">我的简历</el-dropdown-item>
						<el-dropdown-item v-if="utype==2" command="handlerResumePreview">简历预览</el-dropdown-item>
						<el-dropdown-item v-if="utype==2" command="handlerPersonalRecommend">智能推荐</el-dropdown-item>
						<el-dropdown-item v-if="utype==2" command="handlerPersonalService">增值服务</el-dropdown-item>
						<el-dropdown-item v-if="utype==2" command="handlerPersonalPwd">修改密码</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerRefreshJob">刷新职位</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerAddJob">发布职位</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerCompanyPreview">预览主页</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerJobApplyList">收到简历</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerCompanyRecommend">智能推荐</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerCompanyService">会员服务</el-dropdown-item>
						<el-dropdown-item v-if="utype==1" command="handlerCompanyPwd">修改密码</el-dropdown-item>
					</el-dropdown-menu>
				</el-dropdown>
				<el-dropdown v-if="isLogin===false" @command="handlerLogin">
					<a class="header_login right_item" href="javascript:;">会员登录<i
							class="el-icon-arrow-down el-icon--right"></i></a>
					<el-dropdown-menu slot="dropdown">
						<el-dropdown-item command="2">求职者登录</el-dropdown-item>
						<el-dropdown-item command="1">招聘登录</el-dropdown-item>
					</el-dropdown-menu>
				</el-dropdown>
				<el-dropdown v-if="isLogin===false" @command="handlerReg">
					<a class="right_item" href="javascript:;">会员注册<i class="el-icon-arrow-down el-icon--right"></i></a>
					<el-dropdown-menu slot="dropdown">
						<el-dropdown-item command="2">求职者注册</el-dropdown-item>
						<el-dropdown-item command="1">招聘注册</el-dropdown-item>
					</el-dropdown-menu>
				</el-dropdown>
				<el-popover placement="bottom-end" trigger="hover">
					<span class="top-qrcode-item">
						<span class="img"><img :src="mobileQrcode" /></span>
						<span class="txt">触屏版</span>
					</span>
					<span class="top-qrcode-item" v-if="wechatQrcode">
						<span class="img"><img :src="wechatQrcode" /></span>
						<span class="txt">微信公众号</span>
					</span>
					<a class="item_phone right_item phon" href="javascript:;" slot="reference">手机端<i
							class="el-icon-arrow-down el-icon--right"></i></a>
				</el-popover>
				<a class="right_item " href="{#:url('index/help/show')#}">
					使用帮助
				</a>
				<el-popover placement="bottom-end" width="1200" trigger="hover">
					<a class="right_item" href="javascript:;" slot="reference">网站导航<i
							class="el-icon-arrow-down el-icon--right"></i></a>
					<div class="nav_drop">
						<div class="dr_g">
							<div class="g_t">求职找工作</div>
							<div class="g_teg">
								<a href="javascript:;" class="g_it" @click="handlerResumeIndex">登记简历</a>
								<a href="{#:url('index/job/index')#}" class="g_it">找工作</a>
								<a href="{#:url('index/company/index')#}" class="g_it">搜企业</a>
								<a href="{#:url('index/map/index')#}" class="g_it">地图找工作</a>
								<a href="{#:url('index/job/index',['famous'=>1])#}" class="g_it">名企直聘</a>
								<a href="{#:url('index/job/index')#}" class="g_it">最新职位</a>
								<a href="{#:url('index/job/index',['listtype'=>'emergency'])#}" class="g_it">紧急招聘</a>
								<a href="javascript:;" class="g_it" @click="handlerPersonalRecommend">智能匹配</a>
								<div class="clear"></div>
							</div>
						</div>
						<div class="dr_g">
							<div class="g_t">企业招人才</div>
							<div class="g_teg">
								<a href="javascript:;" class="g_it" @click="handlerCompanyIndex">企业入驻</a>
								<a href="javascript:;" class="g_it" @click="handlerAddJob">发布职位</a>
								<a href="{#:url('index/resume/index')#}" class="g_it">搜索简历</a>
								<a href="javascript:;" class="g_it" @click="handlerCompanyJoblist">职位管理</a>
								<a href="javascript:;" class="g_it" @click="handlerCompanyRecommend">人才推荐</a>
								<a href="javascript:;" class="g_it" @click="handlerCompanyService">会员服务</a>
								<div class="clear"></div>
							</div>
						</div>
						<div class="dr_g">
							<div class="g_t">信息专栏</div>
							<div class="g_teg">
								<a href="{#:url('index/jobfairol/index')#}" class="g_it">网络招聘会</a>
								<a href="{#:url('index/notice/index')#}" class="g_it">网站公告</a>
								<a href="{#:url('index/hrtool/index')#}" class="g_it">HR工具箱</a>
								<a href="{#:url('index/article/index')#}" class="g_it">职场资讯</a>
								<div class="clear"></div>
							</div>
						</div>
						<div class="dr_g">
							<div class="g_t">自助工具</div>
							<div class="g_teg">
								<a href="javascript:;" class="g_it" @click="handlerPersonalLogin">求职会员登录</a>
								<a href="javascript:;" class="g_it" @click="handlerCompanyLogin">招聘会员登录</a>
								<a href="javascript:;" class="g_it" @click="handlerForget">忘记密码</a>
								<a href="javascript:;" class="g_it" @click="handlerAppeal">账号申诉</a>
								<a href="{#:url('index/help/show')#}" class="g_it">帮助中心</a>
								<div class="clear"></div>
							</div>
						</div>
					</div>
				</el-popover>
			</div>
		</div>
	</div>
    <!-- 分站弹窗 -->
    <div class="subsite_pupop" v-show="subsite_sel==1" v-cloak>
        <div class="subsite_box">
            <span class="close_icon" @click.stop="subsite_sel=0"></span>
            <div class="subsite_title">
                <div class="text_1">选择城市</div>
                <div class="text_2">切换城市分站，让我们为您提供更准确的信息</div>
            </div>
            <hr>
            <div class="subsite_list">
                <div class="current_site">当前选择城市：<a class="site_link">{#$subsite.sitename|default="总站"#}</a></div>
                <div class="lsit_box clearfix">
                    <span class="item {#if condition="$subsiteid==0"#}active_item{#/if#}" @click.stop="setSubsite(0,sitedomain)">总站</span>
                    <span class="item" :class="item.id==current_subsiteid?'active_item':''" v-for="(item,index) in subsite_list" :key="index"
                        @click.stop="setSubsite(item.id,item.site_url)">{{item.sitename}}</span>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
	$(document).ready(function () {
		// 判断浏览器是否支持placeholder属性
		function isSupportPlaceholder() {
			var input = document.createElement('input');
			return 'placeholder' in input;
		}
		(function () {
			//判断是否是IE浏览器，包括Edge浏览器
			function IEVersion() {
				//取得浏览器的userAgent字符串
				var userAgent = navigator.userAgent;
				//判断是否IE浏览器
				var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
				if (isIE) {
					var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
					reIE.test(userAgent);
					var fIEVersion = parseFloat(RegExp["$1"]);
					if (fIEVersion <= 10 || !isSupportPlaceholder()) {
						return true;
					}
				} else {
					return false;
				}
			}
			window.onload = function () {
				if (IEVersion()) {
					$('.brw_tip').show();
				}
			};
		})();
		$('.J_bw_close').click(function () {
			$(this).closest('.brw_tip').remove();
		});
	})
	var app = new Vue({
		el: '#headerContent',
		data: {
			isLogin: false,
			utype: 0,
			memberUrl: '',
			loginUsername: '',
			preview_id: 0,
			keyword: '',
			searchAlias: 'joblist',
			searchAliasCn: '找工作',
			mobileQrcode: '',
			wechatQrcode: '',
            current_subsiteid:0,
            subsite_open: 0,
            subsite_sel: 0,
            subsite_list: [],
			sitedomain: "{#$global_config.sitedomain#}",
			subsite_domain: ''
		},
		created: function () {
			this.keyword = "{#$Request.param.keyword#}"
			this.getUserInfo()
			this.mobileQrcode = qscms.apiUrl + qscms.apiList.qrcode + "?type=normal&url={#$global_config.mobile_domain#}"
			this.wechatQrcode = "{#$global_config.wechat_qrcode#}"
			this.cronRun()
            this.current_subsiteid = parseInt(qscms.subsiteid)
            this.subsite_open = parseInt("{#$global_config.subsite_open#}")
			this.sitedomain = "{#$global_config.sitedomain#}"
			this.subsite_domain = "{#$global_config.subsite_domain#}"
            this.getConfig()
		},
		methods: {
			setSubsite: function (subsiteid, url = '') {
				if (this.subsite_open === 1 && this.subsite_domain != '') {
					Cookies.set('qscms_subsiteid', subsiteid,
							{domain: '.' + this.subsite_domain}
					)
				} else {
					Cookies.set('qscms_subsiteid', subsiteid,)
				}
				location.replace(url)
			},
            getConfig: function () {
                var that = this
                httpget(qscms.apiList.config)
                    .then(function (res) {
                        that.subsite_list = res.data.subsite_list
                    })
                    .catch(function () { })
            },
			cronRun: function () {
				httpget(qscms.apiList.cronRun)
					.then(function () {
					})
					.catch(function () { })
			},
			AddFavorite: function () {
				var sURL = window.location
				var sTitle = document.title
				try {
					window.external.addFavorite(sURL, sTitle);
				} catch (e) {
					try {
						window.sidebar.addPanel(sTitle, sURL, "");
					} catch (e) {
						this.$confirm('加入收藏失败，请使用Ctrl+D进行添加', '提示', {
							type: 'warning',
							showCancelButton: false
						}).then(function () {
						}).catch(function () { });
					}
				}
			},
			getUserInfo: function () {
				var that = this
				httpget(qscms.apiList.userinfo).then(function (res) {
					if (res.data.login === true) {
						that.isLogin = res.data.login
						that.utype = res.data.userinfo.utype
						if (that.utype == 1) {
							that.memberUrl = qscms.locationList.indexCompany
						} else {
							that.memberUrl = qscms.locationList.indexPersonal
						}
						that.loginUsername = res.data.show_username
						that.preview_id = res.data.preview_id
					}
				}).catch(function () { })
			},
			handlerSearch: function () {
				var that = this
				httpget(qscms.apiList.searchLocation, { alias: that.searchAlias, keyword: that.keyword }).then(function (res) {
					location.href = res.data
				}).catch(function () { })
			},
			changeSearchType: function (alias, aliasCn) {
				this.searchAlias = alias
				this.searchAliasCn = aliasCn
			},
			handlerLogout: function () {
				var that = this
				this.$confirm('确定退出当前账号吗?', '提示', {
					type: 'warning'
				}).then(function () {
					if (that.subsite_open === 1 && that.subsite_domain != '') {
						Cookies.remove('qscms_visitor', {domain: '.' + that.subsite_domain})
					}
					Cookies.remove('qscms_visitor')
					window.location.reload()
				}).catch(function () { })
			},
			handlerLogin: function (utype) {
				if (utype == 1) {
					location.href = qscms.locationList.loginCompany
				} else {
					location.href = qscms.locationList.loginPersonal
				}
			},
			handlerReg: function (utype) {
				if (parseInt("{#$global_config.closereg#}") === 1){
					this.$message.error('网站已关闭会员注册')
					return false
				}
				if (utype == 1) {
					location.href = qscms.locationList.regCompany
				} else {
					location.href = qscms.locationList.regPersonal
				}
			},
			handleManageClick: function (func) {
				this[func]()
			},
			handlerRefreshResume: function () {
				httppost(qscms.apiList.resumeRefresh).then(function (res) {
					if (parseInt(res.code) === 200) {
						this.$message({ type: 'success', message: res.message })
					} else {
						this.$message.error(res.message)
					}
				}).catch(function () { })
			},
			handlerResumeIndex: function () {
				location.href = qscms.locationList.personalResume
			},
			handlerResumePreview: function () {
				var url = "{#:url('index/resume/show',['id'=>'_id_'])#}"
				url = url.replace('_id_', this.preview_id)
				window.open(url)
			},
			handlerPersonalRecommend: function () {
				location.href = qscms.locationList.recommendJob
			},
			handlerPersonalService: function () {
				location.href = qscms.locationList.personalService
			},
			handlerPersonalPwd: function () {
				location.href = qscms.locationList.personalPassword
			},
			handlerRefreshJob: function () {
				this.$confirm('确定刷新所有发布中的职位吗？', '系统提示', {
					type: 'warning'
				})
					.then(function () {
						httppost(qscms.apiList.companyJobRefreshBatch, {}).then(function (res) {
							if (res.data.done === 0) {
								this.$confirm(res.message, '系统提示', { type: 'warning' })
									.then(function () {
										location.href = qscms.locationList.companyJoblist
									})
									.catch(function () { })
								return false
							} else {
								this.$message({ type: 'success', message: res.message })
							}
						}).catch(function () { })
					})
					.catch(function () { })
			},
			handlerAddJob: function () {
				var that = this
				httpget(qscms.apiList.companyCheckJobaddNum, {}).then(function (res) {
					if (res.data.enable_addjob_num <= 0) {
						that.$confirm('您当前是' +
							res.data.setmeal_name +
							'，当前可发布职位数为0，建议您立即升级套餐或将暂时不招聘的职位设为关闭！', '系统提示', {
							confirmButtonText: '升级套餐',
							type: 'warning'
						})
							.then(function () {
								location.href = qscms.locationList.companySetmealAdd
							})
							.catch(function () { })
						return false
					} else {
						location.href = qscms.locationList.companyJobAdd
					}
				}).catch(function () { })
			},
			handlerCompanyPreview: function () {
				var url = "{#:url('index/company/show',['id'=>'_id_'])#}"
				url = url.replace('_id_', this.preview_id)
				window.open(url)
			},
			handlerJobApplyList: function () {
				location.href = qscms.locationList.companyJobApplyList
			},
			handlerCompanyRecommend: function () {
				location.href = qscms.locationList.recommendResume
			},
			handlerCompanyService: function () {
				location.href = qscms.locationList.companyService
			},
			handlerCompanyPwd: function () {
				location.href = qscms.locationList.companyPassword
			},
			handlerCompanyIndex: function () {
				location.href = qscms.locationList.indexCompany
			},
			handlerCompanyLogin: function () {
				location.href = qscms.locationList.loginCompany
			},
			handlerPersonalLogin: function () {
				location.href = qscms.locationList.loginPersonal
			},
			handlerForget: function () {
				location.href = qscms.locationList.forget
			},
			handlerAppeal: function () {
				location.href = qscms.locationList.appeal
			},
			handlerCompanyJoblist: function () {
				location.href = qscms.locationList.companyJoblist
			},
			handlerMemberCenter: function () {
				if (this.utype == 1) {
					location.href = qscms.locationList.indexCompany
				} else {
					location.href = qscms.locationList.indexPersonal
				}
			},
		}
	})
</script>